package com.boss.fileapp.service;

import com.boss.fileapp.dao.IFilePathConfigDao;
import com.boss.fileapp.entity.FilePathConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FilePathConfigService {

    @Autowired
    private IFilePathConfigDao filePathConfigDao;

    /**
     *
     * @param province
     * @return
     */
    public List<FilePathConfig> getFilePathConfigByProvince(String province){
        return filePathConfigDao.selectFilePathConfigByProvince(province);
    }

    public String getUploadDirByDownloadDir(String downloadDir){
        return filePathConfigDao.selectUploadDirByDownloadDir(downloadDir);
    }

    /**
     * 获取银行编码对应上传文件目录路径map
     * @return
     */
    public Map<String,String> getBankCodeAndUploadDir(String province,String sendBankCode){
        List<FilePathConfig> list = filePathConfigDao.selectBankCodeAndUploadDir(province,sendBankCode);
        Map<String, String> map = new HashMap<>();
        for (FilePathConfig filePathConfig : list) {
            map.put(filePathConfig.getBankCode(), filePathConfig.getUploadDirPath());
        }
        return map;
    }

}
